From f07c98fb888a5b56ba15d307a3afbdaf4209eaa3 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Sat, 26 Sep 2026 09:03:12 +0200 Subject: Allow backdating a routine completion --- .../[projectId]/routine/[routineId]/+page.svelte | 29 +++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) (limited to 'src/routes/projects/[projectId]/routine/[routineId]') diff --git a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte index ea292ae..359fd5b 100644 --- a/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte +++ b/src/routes/projects/[projectId]/routine/[routineId]/+page.svelte @@ -17,7 +17,18 @@ let frequency = $state(''); let description = $state(''); let note = $state(''); + let today = $state(''); + let day = $state(''); let saved = $state(false); + // Filled after mount: the server's timezone is not the viewer's. + $effect(() => { + if (today) return; + today = Temporal.Now.instant() + .toZonedDateTimeISO(Temporal.Now.timeZoneId()) + .toPlainDate() + .toString(); + day = today; + }); $effect(() => { name = data.routine.name; frequency = `${data.routine.frequencyDays}d`; @@ -160,6 +171,7 @@ use:enhance={() => { return async ({ update }) => { note = ''; + day = today; await update({ reset: false }); }; }} @@ -172,6 +184,14 @@ placeholder="Note (optionnel)" autocomplete="off" /> + {/if} @@ -244,10 +264,17 @@ .add-completion { flex-direction: row; align-items: center; + flex-wrap: wrap; } + /* Basis wider than the phone width so the note wraps instead of collapsing. */ .add-completion .form-input { - flex: 1; + flex: 1 1 12rem; + } + + .add-completion .done-date { + flex: 0 0 auto; + width: 11rem; } .completion-date { -- cgit v1.3